﻿<dxc:DXWindow x:Class="ThanNhanTao.frmPhieuChayThan"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/core"
         xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
         xmlns:local="clr-namespace:ConvertCustom"
        Title="Phiếu chạy thận" WindowStartupLocation="CenterScreen"
        dxc:ThemeManager.ThemeName="Office2007Blue" Icon="/ThanNhanTao;component/Images/iconbv48x48.ico"
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" Width="520" Height="400">
    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="165"></RowDefinition>
                <RowDefinition></RowDefinition>
                <RowDefinition Height="35"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <GroupBox Grid.Column="0" Grid.Row="0" Margin="2 2 2 2" VerticalAlignment="Top">
        <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30"></RowDefinition>
            <RowDefinition Height="25"></RowDefinition>
            <RowDefinition Height="25"></RowDefinition>
            <RowDefinition Height="25"></RowDefinition>
            <RowDefinition Height="35"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100"></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Label Content="" Height="28" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Name="lblThongTinBenhNhan" VerticalAlignment="Top" FontSize="14" FontWeight="Bold" />
        <Label Content="Lần chạy trước:" Height="28" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="1" Name="lblLanChayTruoc" VerticalAlignment="Top" />
        <Label Content="Số lần chạy tiếp:" Height="28" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="2" Name="lblSoLanChayTiepTheo" VerticalAlignment="Top" />
        <Label Content="Yêu cầu:" Height="28" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="3" Name="lblYeuCau" VerticalAlignment="Top" />
                    <dxe:TextEdit Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left"  MaskType="RegEx" Mask="\d{0,10}" IsReadOnly="True"
                      MaskUseAsDisplayFormat="True" Name="txtLanChayTruoc" VerticalAlignment="Top" Width="150" />
        <dxe:TextEdit Grid.Column="1" Grid.Row="2" 
                      MaskType="RegEx" 
                      MaskUseAsDisplayFormat="True"
                      HorizontalAlignment="Left" Name="txtChayTiepTheo" VerticalAlignment="Top" Width="150" Mask="\d{0,3}" />
        <dxe:ComboBoxEdit Grid.Column="1" Grid.Row="3" HorizontalAlignment="Left" Name="cboYeuCau" VerticalAlignment="Top" Width="150" />
        <Button Content="Tạo phiếu" Grid.Row="4" Margin="0 5 5 5"  Height="23" HorizontalAlignment="Left" Name="buttonTaoPhieu" VerticalAlignment="Center" Width="80" Click="buttonTaoPhieu_Click" />
                    <Button Content="Phiếu đã chạy" Grid.Row="4" Grid.Column="1" Margin="0 5 5 5"  Height="23" HorizontalAlignment="Right" Name="buttonCacPhieuDaChay" VerticalAlignment="Center" Width="100" Click="buttonCacPhieuDaChay_Click" />
                </Grid>
        </GroupBox>
            <dxg:GridControl  Grid.Column="0" Grid.Row="1" Name="GridChayThanNhanTao">
                <dxg:GridControl.Columns>
                    <dxg:GridColumn Name="cluIdBenhNhan" Header="IdBenhNhan" FieldName="IdBenhNhan" Visible="False"/>
                    <dxg:GridColumn Name="cluSTT" Header="STT" Width="60" AllowEditing="False">
                        <dxg:GridColumn.DisplayTemplate>
                            <ControlTemplate>
                                <dxe:TextEdit Text="{Binding Path =Data.RowHandle.Value,Converter ={local:RowHandleToStringConverter},Mode =OneWay}" HorizontalAlignment="Center" EditMode="InplaceActive" />
                            </ControlTemplate>
                        </dxg:GridColumn.DisplayTemplate>
                    </dxg:GridColumn>
                    <dxg:GridColumn Name="cluNgayChay" Header="Ngày chạy"  FieldName="NgayChay" AllowEditing="True" Width="100" Validate="cluNgayChay_Validate">
                        <dxg:GridColumn.EditSettings>
                            <dxe:DateEditSettings DisplayFormat="dd/MM/yyyy" Mask="dd/MM/yyyy" HorizontalContentAlignment="Center"/>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                    <dxg:GridColumn Name="cluLanChay" Header="Lần chạy thứ" FieldName="LanChay" AllowEditing="True" Width="100" Validate="cluLanChay_Validate"/>
                    <dxg:GridColumn Name="cluMaYeuCau" Header="Mã yêu cầu" FieldName="obChiDinh.MaYeuCau" AllowEditing="False" Width="100"/>
                    <dxg:GridColumn Name="cluPrint" Header="In phiếu" FieldName="PrintPhieu" AllowEditing="True" Width="70"/>
                    <dxg:GridColumn Width="30" AllowResizing="False" Header="" AllowEditing="False" FieldName="Xoa" Name="btnXoaRowDinhMuc" AllowMoving="False" ReadOnly="True">
                        <dxg:GridColumn.DisplayTemplate>
                            <ControlTemplate>
                                <Button Name="btnDelRowDinhMuc" Content="x" Click="btnDelRowDinhMuc_Click">
                                </Button>
                                <ControlTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Data.delete}" Value="true">
                                        <Setter Property="FontWeight" Value="Bold" TargetName="btnDelRowDinhMuc" />
                                        <Setter Property="Visibility" Value="Visible" TargetName="btnDelRowDinhMuc" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Data.delete}" Value="false">
                                        <Setter Property="Visibility" Value="Hidden" TargetName="btnDelRowDinhMuc" />
                                    </DataTrigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </dxg:GridColumn.DisplayTemplate>
                    </dxg:GridColumn>
                    <dxg:GridColumn Width="30" AllowResizing="False" Header="" AllowEditing="False" FieldName="Xoa" Name="btnXoaRowDinhMucDaChay" AllowMoving="False" ReadOnly="True">
                        <dxg:GridColumn.DisplayTemplate>
                            <ControlTemplate>
                                <Button Name="btnDelRowDinhMucDaChay" Content="x" Click="btnDelRowDinhMucDaChay_Click">
                                </Button>
                                <ControlTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Data.delete}" Value="true">
                                        <Setter Property="FontWeight" Value="Bold" TargetName="btnDelRowDinhMucDaChay" />
                                        <Setter Property="Visibility" Value="Visible" TargetName="btnDelRowDinhMucDaChay" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Data.delete}" Value="false">
                                        <Setter Property="Visibility" Value="Hidden" TargetName="btnDelRowDinhMucDaChay" />
                                    </DataTrigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </dxg:GridColumn.DisplayTemplate>
                    </dxg:GridColumn>
                </dxg:GridControl.Columns>
                <dxg:GridControl.View>
                    <dxg:TableView ShowAutoFilterRow="True" MaxHeight="1800" Name="TBvChayThan"
                                           ShowGroupedColumns="False" ShowColumnHeaders="True" 
                                           ShowGroupPanel="False" AutoWidth="False" AllowEditing="False" 
                                           AllowDrop="False" AllowGrouping="False" AllowMoveColumnToDropArea="False" 
                                           AllowMoving="False" IsColumnMenuEnabled="False" IsDeferredScrolling="False" 
                                           IsGroupPanelMenuEnabled="False" IsRowCellMenuEnabled="False" 
                                           IsTotalSummaryMenuEnabled="False"
                                   FocusedRowChanged="TBvChayThan_FocusedRowChanged">
                    </dxg:TableView>
                </dxg:GridControl.View>
            </dxg:GridControl>
            <Button Content="In phiếu" Margin="5 5 5 5" Grid.Row="2" Grid.Column="1" Height="23" HorizontalAlignment="Left" Name="buttonInPhieu" VerticalAlignment="Center" Width="80" Click="buttonInPhieu_Click" />
            <Button Content="In phiếu" Visibility="Hidden" Margin="5 5 5 5" Grid.Row="2" Grid.Column="1" Height="23" HorizontalAlignment="Left" Name="buttonInPhieuDaChay" VerticalAlignment="Center" Width="80" Click="buttonInPhieuDaChay_Click" />
            <Button Content="Cập nhật" Margin="5 5 90 5" Grid.Row="2" Grid.Column="1" Height="23" HorizontalAlignment="Right" Name="buttonCapNhat" Visibility="Hidden" VerticalAlignment="Center" Width="80" Click="buttonCapNhat_Click" />
            <Button Content="Đóng" Margin="5 5 5 5" Grid.Row="2" Grid.Column="1" Height="23" HorizontalAlignment="Right" Name="buttonDong" VerticalAlignment="Center" Width="80" Click="buttonDong_Click" />
        </Grid>
    </Grid>
</dxc:DXWindow>
